package org.mattmckay.PDFd.Layer;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import PDFd.Layer.DrawingUtilities;
import PDFd.Layer.Point;

import junit.framework.TestCase;

public class GenericDrawingUtilitiesTest extends TestCase {

	protected void setUp() throws Exception {
		super.setUp();
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	public final void testGetPointsBetween() {
		//test with same point twice (should return 1 point)
		Map<Point, Integer> test = new HashMap<Point,Integer>();
		Point p = new Point(0,0);
		test = DrawingUtilities.getPointsBetween(new Point(0,0), 0, new Point(0,0), 0);
		//check to see that the only point in test is 0,0 and maps to 0
		assertTrue(test.size() == 1);
		assertTrue(test.get(new Point(0,0)) != null);
		assertTrue(test.get(new Point(0,0)) == 0);
		
		//test with different close points
		test = DrawingUtilities.getPointsBetween(new Point(0,0), 0, new Point(0,2), 2);
		assertTrue(test.size() == 2);
		assertTrue(test.get(new Point(0,0)) != null);
		assertTrue(test.get(new Point(0,0)) == 0);
		assertTrue(test.get(new Point(0,2)) != null);
		assertTrue(test.get(new Point(0,2)) == 2);
		
		//test with different not-close points
		test = DrawingUtilities.getPointsBetween(new Point(0,0), 0, new Point(0,5), 5);
		assertTrue(test.size() == 3);
		assertTrue(test.get(new Point(0,0)) != null);
		assertTrue(test.get(new Point(0,0)) == 0);
		assertTrue(test.get(new Point(0,5)) != null);
		assertTrue(test.get(new Point(0,5)) == 5);
		assertTrue(test.get(new Point(0,3)) != null);
		assertTrue(test.get(new Point(0,3)) < 5 && test.get(new Point(0,3)) > 0);
		
	}

}
